<template>
  <el-dialog
    :visible.sync="visible"
    :before-close="beforeClose"
    :close-on-click-modal="false"
    append-to-body
    title="附件"
    width="800px"
    top="30px"
  >
    <div style="min-height: 220px">
      <div v-for="(p, index) of attachArray" :key="index">
        <a :href="p.url" target="_blank">{{ p.name }}</a>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import { arrayFromString } from '@vimi/utils-tool'
export default {
  props: {
    visible: Boolean,
    attach: String,
  },
  data() {
    return {}
  },
  computed: {
    attachArray() {
      const data = arrayFromString(this.attach)
      return data.map(item => {
        return {
          url: item,
          name: item.replace(/.*\/(.*)$/, '$1'),
        }
      })
    },
  },
  created() {},
  methods: {
    beforeClose() {
      this.$emit('update:visible', false)
    },
  },
}
</script>
<style lang="scss" scoped></style>
